package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("shop/type")
public class TbTypeController {
    @Autowired
    TbTypeService tbTypeService;
    @PostMapping("/addType")
    public Result addType(@RequestBody TbType tbType){
        return tbTypeService.addType(tbType);
    }
    @PostMapping("/deleteType/{typeId}")
    public Result deleteType(@PathVariable("typeId")Integer typeId){
        return tbTypeService.deleteType(typeId);
    }
    @GetMapping("/getTypeTree")
    public Result getTypeTree(){
        return tbTypeService.getTypeTree();
    }
    @PostMapping("/setTypeStatus/{typeId}/{typeStatus}")
    public Result setTypeStatus(@PathVariable("typeId")Integer typeId,@PathVariable("typeStatus")Integer typeStatus){
        return tbTypeService.setTypeStatus(typeId,typeStatus);
    }
    @PostMapping("/deleteTypeById/{typeId}")
    public Result deleteTypeById(@PathVariable("typeId")Integer typeId){
        return tbTypeService.deleteTypeById(typeId);
    }
    @PostMapping("/uploadFile")
    public Result uploadFile(@RequestPart("file")MultipartFile file){
        return tbTypeService.uploadFile(file);
    }
    @PostMapping("/updateType")
    public Result updateType(@RequestBody TbType tbType){
        return tbTypeService.updateType(tbType);
    }
    @GetMapping("/getTypeSelectTree")
    public Result getTypeSelectTree(){
        return tbTypeService.getTypeSelectTree();
    }
}
